namespace CaltechSoft.Service.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class init : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.CertificateDetails",
                c => new
                    {
                        CertificateDetailsId = c.Int(nullable: false, identity: true),
                        CertificateId = c.Int(nullable: false),
                        CertificateStandardId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.CertificateDetailsId)
                .ForeignKey("dbo.Certificate", t => t.CertificateId, cascadeDelete: true)
                .ForeignKey("dbo.CertificateStandard", t => t.CertificateStandardId, cascadeDelete: true)
                .Index(t => t.CertificateId)
                .Index(t => t.CertificateStandardId);
            
            CreateTable(
                "dbo.Certificate",
                c => new
                    {
                        CertificateId = c.Int(nullable: false, identity: true),
                        CertificateNo = c.String(),
                        CustomerId = c.Int(nullable: false),
                        EquipmentId = c.Int(nullable: false),
                        ConditionReceivedId = c.String(),
                        ConditionReturnedId = c.String(),
                        Temperature = c.String(),
                        RelativeHumidity = c.String(),
                        CalibrationCycle = c.String(),
                        CalibrationDate = c.DateTime(nullable: false),
                        NextDueDate = c.DateTime(nullable: false),
                        CertifiedBy = c.String(),
                        Technician = c.String(),
                        QualityInspector = c.String(),
                        Manufacturer = c.String(),
                        Description = c.String(),
                        ModelNumber = c.String(),
                        SerialNumber = c.String(),
                        PONumber = c.String(),
                        Procedure = c.String(),
                        AssetNumber = c.String(),
                        Remarks = c.String(),
                        CreatedBy = c.Int(nullable: false),
                        CreatedDate = c.DateTime(),
                        UpdatedDate = c.DateTime(),
                        UpdatedBy = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.CertificateId);
            
            CreateTable(
                "dbo.CertificateStandard",
                c => new
                    {
                        CertificateStandardId = c.Int(nullable: false, identity: true),
                        StandardNo = c.String(),
                        Manufacturer = c.String(),
                        ModelNumber = c.String(),
                        SerialNumber = c.String(),
                        DueDate = c.DateTime(nullable: false),
                        TestReportNumber = c.String(),
                        CreatedBy = c.Int(nullable: false),
                        CreatedDate = c.DateTime(),
                        UpdatedDate = c.DateTime(),
                        UpdatedBy = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.CertificateStandardId);
            
            CreateTable(
                "dbo.Customers",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Address = c.String(),
                        Tel = c.String(),
                        Mobile = c.String(),
                        ContactPersonName = c.String(),
                        Email = c.String(),
                        Fax = c.String(),
                        NextDueDate = c.DateTime(),
                        CreatedBy = c.Int(nullable: false),
                        CreatedDate = c.DateTime(),
                        UpdatedDate = c.DateTime(),
                        UpdatedBy = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Equipment",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Manufacturer = c.String(),
                        Description = c.String(),
                        ModelNumber = c.String(),
                        SerialNumber = c.String(),
                        PONumber = c.String(),
                        Procedure = c.String(),
                        AssetNumber = c.String(),
                        CalibrationDate = c.DateTime(),
                        NextDueDate = c.DateTime(),
                        Name = c.String(),
                        CustomerId = c.Int(nullable: false),
                        CreatedBy = c.Int(nullable: false),
                        CreatedDate = c.DateTime(),
                        UpdatedDate = c.DateTime(),
                        UpdatedBy = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.QuoteItems",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Quantity = c.Int(nullable: false),
                        UnitPrice = c.Long(nullable: false),
                        EquipmentId = c.Int(nullable: false),
                        QuoteId = c.Int(nullable: false),
                        CreatedBy = c.Int(nullable: false),
                        CreatedDate = c.DateTime(),
                        UpdatedDate = c.DateTime(),
                        UpdatedBy = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Equipment", t => t.EquipmentId, cascadeDelete: true)
                .ForeignKey("dbo.Quotes", t => t.QuoteId, cascadeDelete: true)
                .Index(t => t.EquipmentId)
                .Index(t => t.QuoteId);
            
            CreateTable(
                "dbo.Quotes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        QuoteDate = c.DateTime(),
                        ServiceCharges = c.Long(nullable: false),
                        Tax = c.Long(nullable: false),
                        CompanyId = c.Int(nullable: false),
                        SalesmanId = c.String(maxLength: 128),
                        CreatedBy = c.Int(nullable: false),
                        CreatedDate = c.DateTime(),
                        UpdatedDate = c.DateTime(),
                        UpdatedBy = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Customers", t => t.CompanyId, cascadeDelete: true)
                .ForeignKey("dbo.AspNetUsers", t => t.SalesmanId)
                .Index(t => t.CompanyId)
                .Index(t => t.SalesmanId);
            
            CreateTable(
                "dbo.AspNetUsers",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        Tel = c.String(),
                        FirstName = c.String(),
                        LastName = c.String(),
                        BillingAddress = c.String(),
                        BillingPOBox = c.String(),
                        BillingZipCode = c.String(),
                        BillingCity = c.String(),
                        BillingCountry = c.String(),
                        IsDeleted = c.Boolean(nullable: false),
                        Email = c.String(maxLength: 256),
                        EmailConfirmed = c.Boolean(nullable: false),
                        PasswordHash = c.String(),
                        SecurityStamp = c.String(),
                        PhoneNumber = c.String(),
                        PhoneNumberConfirmed = c.Boolean(nullable: false),
                        TwoFactorEnabled = c.Boolean(nullable: false),
                        LockoutEndDateUtc = c.DateTime(),
                        LockoutEnabled = c.Boolean(nullable: false),
                        AccessFailedCount = c.Int(nullable: false),
                        UserName = c.String(nullable: false, maxLength: 256),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.UserName, unique: true, name: "UserNameIndex");
            
            CreateTable(
                "dbo.AspNetUserClaims",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserId = c.String(nullable: false, maxLength: 128),
                        ClaimType = c.String(),
                        ClaimValue = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.AspNetUserLogins",
                c => new
                    {
                        LoginProvider = c.String(nullable: false, maxLength: 128),
                        ProviderKey = c.String(nullable: false, maxLength: 128),
                        UserId = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => new { t.LoginProvider, t.ProviderKey, t.UserId })
                .ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.AspNetUserRoles",
                c => new
                    {
                        UserId = c.String(nullable: false, maxLength: 128),
                        RoleId = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => new { t.UserId, t.RoleId })
                .ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
                .ForeignKey("dbo.AspNetRoles", t => t.RoleId, cascadeDelete: true)
                .Index(t => t.UserId)
                .Index(t => t.RoleId);
            
            CreateTable(
                "dbo.AspNetRoles",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        Name = c.String(nullable: false, maxLength: 256),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.Name, unique: true, name: "RoleNameIndex");
            
            CreateTable(
                "dbo.Term",
                c => new
                    {
                        TermId = c.Int(nullable: false, identity: true),
                        TermName = c.String(),
                        Description = c.String(),
                        Price = c.Decimal(precision: 18, scale: 2),
                        IsPublished = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.TermId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.AspNetUserRoles", "RoleId", "dbo.AspNetRoles");
            DropForeignKey("dbo.Quotes", "SalesmanId", "dbo.AspNetUsers");
            DropForeignKey("dbo.AspNetUserRoles", "UserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.AspNetUserLogins", "UserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.AspNetUserClaims", "UserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.QuoteItems", "QuoteId", "dbo.Quotes");
            DropForeignKey("dbo.Quotes", "CompanyId", "dbo.Customers");
            DropForeignKey("dbo.QuoteItems", "EquipmentId", "dbo.Equipment");
            DropForeignKey("dbo.CertificateDetails", "CertificateStandardId", "dbo.CertificateStandard");
            DropForeignKey("dbo.CertificateDetails", "CertificateId", "dbo.Certificate");
            DropIndex("dbo.AspNetRoles", "RoleNameIndex");
            DropIndex("dbo.AspNetUserRoles", new[] { "RoleId" });
            DropIndex("dbo.AspNetUserRoles", new[] { "UserId" });
            DropIndex("dbo.AspNetUserLogins", new[] { "UserId" });
            DropIndex("dbo.AspNetUserClaims", new[] { "UserId" });
            DropIndex("dbo.AspNetUsers", "UserNameIndex");
            DropIndex("dbo.Quotes", new[] { "SalesmanId" });
            DropIndex("dbo.Quotes", new[] { "CompanyId" });
            DropIndex("dbo.QuoteItems", new[] { "QuoteId" });
            DropIndex("dbo.QuoteItems", new[] { "EquipmentId" });
            DropIndex("dbo.CertificateDetails", new[] { "CertificateStandardId" });
            DropIndex("dbo.CertificateDetails", new[] { "CertificateId" });
            DropTable("dbo.Term");
            DropTable("dbo.AspNetRoles");
            DropTable("dbo.AspNetUserRoles");
            DropTable("dbo.AspNetUserLogins");
            DropTable("dbo.AspNetUserClaims");
            DropTable("dbo.AspNetUsers");
            DropTable("dbo.Quotes");
            DropTable("dbo.QuoteItems");
            DropTable("dbo.Equipment");
            DropTable("dbo.Customers");
            DropTable("dbo.CertificateStandard");
            DropTable("dbo.Certificate");
            DropTable("dbo.CertificateDetails");
        }
    }
}
